package com.kc.web.controller.business;

import com.kc.business.domain.BizArtOrder;
import com.kc.business.domain.vo.BizProcameraOrder;
import com.kc.business.service.IBizArtOrderService;
import com.kc.business.service.IBizProcameraOrderService;
import com.kc.business.service.IBizUserService;
import com.kc.common.annotation.Log;
import com.kc.common.annotation.RepeatSubmit;
import com.kc.common.core.controller.BaseController;
import com.kc.common.core.domain.AjaxResult;
import com.kc.common.core.page.TableDataInfo;
import com.kc.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * TODO
 *
 * @author zhangshuo
 * @version 1.0
 * @date 2020/10/6
 */
@RestController
@RequestMapping("/business/procameraOrder")
public class BizProcameraOrderController extends BaseController {
    @Autowired
    private IBizProcameraOrderService procameraOrderService;
    @Autowired
    private IBizArtOrderService artOrderService;

    /**
     * 拍客订单列表
     */
    @PreAuthorize("@ss.hasPermi('business:procameraOrder:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizProcameraOrder procameraOrder) {
        startPage();
        List<BizProcameraOrder> list = procameraOrderService.getList(procameraOrder);
        return getDataTable(list);
    }

    /**
     * 拍客订单审核
     */
    @PreAuthorize("@ss.hasPermi('business:procameraOrder:edit')")
    @Log(title = "拍客订单审核", businessType = BusinessType.UPDATE)
    @PutMapping
    @RepeatSubmit
    @Transactional
    public AjaxResult edit(@RequestBody @Validated BizProcameraOrder bizShopEnterForm) {
        if("2".equals(bizShopEnterForm.getStatus())){
            BizArtOrder artOrder = new BizArtOrder();
            artOrder.setOrderStatus("0");
            artOrderService.edit(artOrder);
        }
        return toAjax(procameraOrderService.edit(bizShopEnterForm));
    }
}
